package io.aggression.test.handler;

import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.Headers;
import io.undertow.server.session.SessionConfig;
import io.undertow.server.session.Session;
import io.undertow.server.session.SessionManager;

public class DefaultHandler implements HttpHandler {

	@Override
	public void handleRequest(HttpServerExchange exchange) throws Exception{

		SessionManager sessionManager = exchange.getAttachment(SessionManager.ATTACHMENT_KEY);
		SessionConfig sessionConfig = exchange.getAttachment(SessionConfig.ATTACHMENT_KEY);

		Session session = sessionManager.getSession(exchange, sessionConfig);
			if (session == null )
				sessionManager.createSession(exchange,sessionConfig);


		exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
		exchange.getResponseSender().send("Hello World!");

	}


}
